#ifndef PARSETHREAD_H
#define PARSETHREAD_H

#include <QMutex>
#include <QObject>
#include <QQueue>
#include <QThread>
#include <QWaitCondition>
#include <QImage>

//包头长度12
struct PackageHeader{
    quint32         startOfFrameDelimiter;//帧起始符

    quint32         lengthOfFrame;  //帧长度

    quint32         typeOfFrame;    //帧类型
};

struct PackageBody{

    PackageHeader   header;

    quint32         test1;

    quint32         test2;

    quint32         test3;
};

class ParseThread : public QThread
{
    Q_OBJECT
public:
    explicit ParseThread(QObject *parent = nullptr);
    ~ParseThread();
    void recvData(QByteArray);
protected:
    void run();
signals:
    void signRecvPhotoInfo();
private:
    void handleData(QByteArray& data);

    void handleParseImageData(PackageBody& data);
private:
    //数据锁
    QMutex                          m_mutex;
    //数据队列
    QQueue<QByteArray>              m_dataQueue;
    //信号量
    QWaitCondition                  m_waitCondition;

    bool                            m_stop;

};

#endif // PARSETHREAD_H
